package elven.d.web.event.listener;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.event.SmartApplicationListener;

import elven.d.common.log.LogFactory;
import elven.d.web.event.hello.ContentEvent;

/**
 * 孙六事件监听器，有序的监听事件，在李四之后执行
 * @author liuyongyuan
 */
public class SunliuListener implements SmartApplicationListener {

	@Override
	public void onApplicationEvent(ApplicationEvent event) {
		LogFactory.d().info("孙六在李四收到消息之后收到新的内容：{}",event.getSource());
	}

	/**
	 * 李四是1，孙六在李四之后，应当要设置为2
	 * @return
	 */
	@Override
	public int getOrder() {
		return 2;
	}

	@Override
	public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
		return eventType == ContentEvent.class;
	}

	@Override
	public boolean supportsSourceType(Class<?> sourceType) {
		return sourceType == String.class;
	}

}
